package de.laures.cewolf.util;

import java.util.LinkedList;
import java.util.List;

import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.CombinedDomainCategoryPlot;
import org.jfree.chart.plot.CombinedDomainXYPlot;
import org.jfree.chart.plot.CombinedRangeCategoryPlot;
import org.jfree.chart.plot.CombinedRangeXYPlot;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.XYPlot;

public class ChartUtils {
	public static List<Plot> getPlots(Plot plot) {
		List<Plot> plots = new LinkedList<Plot>();
		if (plot instanceof CombinedDomainXYPlot) {
			plots = ((CombinedDomainXYPlot) plot).getSubplots();
		}
		else if (plot instanceof CombinedDomainCategoryPlot) {
			plots = ((CombinedDomainCategoryPlot) plot).getSubplots();
		}
		else if (plot instanceof CombinedRangeXYPlot) {
			plots = ((CombinedRangeXYPlot) plot).getSubplots();
		}
		else if (plot instanceof CombinedRangeCategoryPlot) {
			plots = ((CombinedRangeCategoryPlot) plot).getSubplots();
		}
		else if (plot instanceof XYPlot) {
			plots.add(plot);
		}
		else if (plot instanceof CategoryPlot) {
			plots.add(plot);
		}
		return plots;
	}
}
